package com.decent.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.decent.entity.Card;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * @Author decent
 * @Create 2021/4/10 - 14:01
 * @Description
 */
@Mapper
public interface CardMapper extends BaseMapper<Card> {

    /**
     * 插入卡卷
     * @param cards
     * @return
     */
    @Insert("<script>" +
            "INSERT INTO `card` (        " +
            "card_number, " +
            "card_pwd, " +
            "card_link, " +
            "card_type, " +
            "purchase_date, " +
            "effective_time, " +
            "complete_time, " +
            "order_id, " +
            "product_id, " +
            "order_no)\n" +
            "VALUES\n" +
            "<foreach collection=\"list\" item=\"card\" separator=\",\">\n" +
            "   (#{card.cardNumber},#{card.cardPwd},#{card.cardLink},#{card.cardType},\n" +
            "    #{card.purchaseDate},#{card.effectiveTime},#{card.completeTime},#{card.orderId},#{card.productId},\n" +
            "    #{card.orderNo})\n" +
            "</foreach>\n" +
            "</script>")
    int insertCards(List<Card> cards);


}
